package store.lunangangster.engine.bpmn.parser.handler;

import store.lunangangster.bpmn.model.EndEvent;
import store.lunangangster.bpmn.model.Event;
import store.lunangangster.bpmn.model.definition.EventDefinition;
import store.lunangangster.engine.bpmn.parser.BpmnParser;
import store.lunangangster.engine.impl.bpmn.behavior.NoneEndEventBehavior;

/**
 * 解析{@link EndEvent}的{@link EventDefinition}并为其添加相应的Behavior，包括:
 * <ul>
 *   <li>{@link NoneEndEventBehavior}</li>
 * </ul>
 *
 * @author cwk
 * @version 1.0
 */
public class EndEventParseHandler extends EventParseHandler<EndEvent> {

  @Override
  public void handle0(BpmnParser bpmnParser, EndEvent endEvent) {
    if (endEvent.getEventDefinitions() == null || endEvent.getEventDefinitions().isEmpty()) {
      endEvent.setBehavior(new NoneEndEventBehavior());
    } else {
      // TODO 解析其他类型的EndEvent
      // for (EventDefinition eventDefinition : endEvent.getEventDefinitions()) {
      //
      // }
    }
  }

  @Override
  public Class<? extends Event> getType() {
    return EndEvent.class;
  }
}
